<?php
//error_reporting(E_ALL);
/*
 * Main Pages: Login, Register, Userpage
 * First check user login: create user / login user
 * 
 * Set sessionToken (Cookie) if login form has been send
 * If sessionToken is not set, show login form / register form
 * 
 * Output with XSLT Stylsheets and XMLData(DOM)
 */

define("PHP_DIR", "php/");
define("XML_DIR", "xml/");
include PHP_DIR."database.php";
include PHP_DIR."domextension.php";
include PHP_DIR."user.php";
include PHP_DIR."loginregister.php";
include PHP_DIR."easyshopping.php";

//known user? check loginform / cookie => token in db?
//unknown user, login form? else registerform
//first get form inputs

//show userpage if login successfull
if(isset($_POST["login"])) new login($_POST["nickname"], md5($_POST["password"]));
//show userpage if registration successfull
elseif(isset($_POST["register"])) new register($_POST["arrData"]);	
//show userpage if cookiecheck successfull
elseif(login::loginstate($_COOKIE[User::cookie])) new Easyshopping(new User($_COOKIE[User::cookie]));
//show registration form 
elseif(isset($_POST["registerform"])) register::form();
//show login form
else login::form();